package com.it.you.base.designmode.singleton;

import java.util.concurrent.atomic.AtomicLong;

/**
 * Java 枚举类型本身的特性，保证了实例创建的线程安全性和实例的唯一性。
 */
public enum IdGenerator_Enum {
    INSTANCE;
    private final AtomicLong id = new AtomicLong(0);

    public long getId() {
        return id.incrementAndGet();
    }
}
